// var usb = require('usb');

// usb.on('attach', function(device) {
// 	console.log(device);
// });

// var devList = usb.getDeviceList();
// console.log(devList);

/*
 * Windows api
 */
var ref = require('ref');
var ffi = require('ffi');

function TEXT(text){
return new Buffer(text, 'ucs2').toString('binary');
}
/*
var user32 = new ffi.Library('user32', {
'MessageBoxW':
[
'int32', [ 'int32', 'string', 'string', 'int32' ]
]
});
var result = user32.MessageBoxW(0, TEXT('I am Node.JS!'), TEXT('Hello, World!'), 1);
console.log("result:: ", result);
*/

//Windows driver api
var kernel32 = new ffi.Library('kernel32', {
    'GetLogicalDrives': ['int32', [ ]],
    'GetDriveTypeW': ['uint32', ['string']],
    'GetDiskFreeSpaceExW': ['int32', ['string', ref.refType('uint64'), ref.refType('uint64'), ref.refType('uint64')]]
});

var drivers = kernel32.GetLogicalDrives();
console.log("drivers:: ", drivers);

var driverType = kernel32.GetDriveTypeW(TEXT('F:\\'));
console.log("driverType:: ", driverType);

freeBytesAvailable = ref.alloc('uint64');
totalNumberOfBytes = ref.alloc('uint64');
totalNumberOfFreeBytes = ref.alloc('uint64');
kernel32.GetDiskFreeSpaceExW(TEXT('F:\\'), freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes);
freeBytesAvailable = freeBytesAvailable.deref();
totalNumberOfBytes = totalNumberOfBytes.deref();
console.log("driver total space:: ", totalNumberOfBytes / 1024 / 1024 / 1024, "GB");
console.log("driver free space:: ", freeBytesAvailable / 1024 / 1024 / 1024, "GB");